package com.snif.web.attach;

import lombok.extern.slf4j.Slf4j;



import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
import java.util.HashMap;
import java.util.Map;

/**
 * AgentMain
 *
 * @author Yakir
 */

public class AgentMain {

	// JVM启动时执行
	public static void premain(String agentArgs, Instrumentation inst) {
		System.out.println("web-attach增强应用启动中...");

		initAgent(inst, agentArgs);
	}

	// JVM运行时动态附着
	public static void agentmain(String agentArgs, Instrumentation inst) {
		System.out.println("动态web-attach增强探针应用...");
		initAgent(inst, agentArgs);
	}

	private static void initAgent(Instrumentation inst, String agentArgs) {
		// 注册Spring组件扫描增强器
		Transformer transformer = new Transformer(inst,agentArgs);
		inst.addTransformer(transformer, true);

	}


}
